<!DOCTYPE html>
<html lang="en-us" id="extr-page">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../global/css/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
    <link rel="stylesheet" href="../../global/css/ztree/demo.css" type="text/css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <form class="form-horizontal" onsubmit="return false" id="form">
        <fieldset>
            <input type="hidden" id="id" name="id">
            <input type="hidden" id="shopsId" name="shopsId">
            <div class="form-group">
                <label class="col-md-2 control-label">方案名称:</label>
                <div class="col-md-10">
                    <input class="form-control" placeholder="方案名称" type="text" name="schemeName" id="schemeName"
                           data-bv-notempty="true"
                           data-bv-notempty-message="方案名称不能为空">
                </div>
            </div>
           <div class="form-group">
                           <label class="col-md-2 control-label">起送价格:</label>
                           <div class="col-md-10">
                               <input class="form-control" placeholder="起送价格" type="text" name="beginPrice" id="beginPrice"
                                      data-bv-notempty="true"
                                      data-bv-notempty-message="起送价格不能为空">
                           </div>
                       </div>
          <div class="form-group">
                          <label class="col-md-2 control-label">起送距离:</label>
                          <div class="col-md-10">
                              <input class="form-control" placeholder="起送距离" type="text" name="beginRange" id="beginRange"
                                     data-bv-notempty="true"
                                     data-bv-notempty-message="起送距离不能为空">
                          </div>
                      </div>
           <div class="form-group">
                           <label class="col-md-2 control-label">每公里加价:</label>
                           <div class="col-md-10">
                               <input class="form-control" placeholder="每公里加价" type="text" name="beginPriceMarkup" id="beginPriceMarkup"
                                      data-bv-notempty="true"
                                      data-bv-notempty-message="每公里加价不能为空">
                           </div>
                       </div>
           <div class="form-group">
                           <label class="col-md-2 control-label">起送重量:</label>
                           <div class="col-md-10">
                               <input class="form-control" placeholder="起送重量" type="text" name="beginWeight" id="beginWeight"
                                      data-bv-notempty="true"
                                      data-bv-notempty-message="起送重量不能为空">
                           </div>
                       </div>
             <div class="form-group">
                                       <label class="col-md-2 control-label">每公斤加价:</label>
                                       <div class="col-md-10">
                                           <input class="form-control" placeholder="每公斤加价" type="text" name="weightMarkup" id="weightMarkup"
                                                  data-bv-notempty="true"
                                                  data-bv-notempty-message="每公斤加价不能为空">
                                       </div>
                                   </div>
            <div class="form-group">
                                        <label class="col-md-2 control-label">状态:</label>
                                        <div class="col-md-10" style="width: 120px">
                                         <select class="form-control input-sm" name="status" id="status">
                                         <option value="0" selected="selected">请选择</option>
                                         <option value="1" >启用</option>
                                         <option value="2" >禁用</option> </select>
                                    </div>
                                    </div>
            <div class="form-actions">
                <div class="row" align="center">
                    <div class="col-md-12">
                        <button class="btn btn-primary" onclick="location.href='schemeList.html'">返回</button>
                        <button class="btn btn-primary" type="submit" onclick="add()">
                            <i class="fa fa-save"></i> 保存
                        </button>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../global/js/common.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/libs/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="../../global/js/my/ztree-menu.js"></script>
<script type="text/javascript">

        layui.use('layer', function () {
            var layer = layui.layer;
        });

        initData();

    function initData() {
        var id = getUrlParam("id");
        if (id != "") {
            $.ajax({
                type: 'get',
                url: '/clyjNearbyShopsScheme/' + id,
                async: false,
                success: function (result) {
                    var data = result.data;
                    $("#id").val(data.id);
                    $("#shopsId").val(data.shopsId);
                    $("#schemeName").val(data.schemeName);
                    $("#beginPrice").val(data.beginPrice);
                    $("#beginRange").val(data.beginRange);
                    $("#beginPriceMarkup").val(data.beginPriceMarkup);
                    $("#beginWeight").val(data.beginWeight);
                    $("#weightMarkup").val(data.weightMarkup);
                    $("#status").val(data.status);
                }
            });

        }
    }
    $('#form').bootstrapValidator();

    function add() {
        var bootstrapValidator = $("#form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (!bootstrapValidator.isValid()) {
            return;
        }

        var formdata = $("#form").serializeObject();

        $.ajax({
            type: 'post',
            url: '/clyjNearbyShopsScheme/saveScheme',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(formdata),
            success: function (data) {
                layer.msg("成功", {shift: -1, time: 1000}, function () {
                    location.href = "schemeList.html";
                });
            }
        });
    }

</script>
</body>
</html>